package com.xiaowen.tool.threadUtil;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created with IntelliJ IDEA.
 * User: yf-wenhao
 * Date: 17/8/11
 * Time: 上午9:47
 */
public class ThreadFactory implements java.util.concurrent.ThreadFactory {

    private AtomicInteger count = new AtomicInteger(0);

    @Override
    public Thread newThread(Runnable r) {
        Thread t = new Thread(r);
        String threadName = ThreadFactory.class.getSimpleName() + count.addAndGet(1);
        t.setName(threadName);
        return t;
    }

}
